package main

import (
	"flag"

	"engine"
	"engine/eng_cfg"
	"engine/log"
	"gitee.com/ameise84/e3utils/sys"
	"gitee.com/ameise84/e3utils/utils"
	"github.com/spf13/viper"
	_ "servers/app/node/gw_game/service"
)

func main() {
	defaultPath := utils.GetCurrentExeDir()
	flag.Parse()
	args := flag.Args()
	if len(args) == 1 {
		defaultPath = args[0]
	}

	viper.SetDefault(eng_cfg.AppNode, utils.GetCurrentExtFileName())
	err := engine.Start(defaultPath, nil)
	if err == nil {
		log.GetLogger().Info("engine start").Str("state", "running").Println()
		sys.WaitKillSigint()
		engine.Stop(nil)
	} else {
		log.GetLogger().Error("engine start", false).Err(err).Println()
	}
	log.GetLogger().Wait()
}
